﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>职称设置 - 修改</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
    <script src="https://unpkg.com/element-plus/dist/index.full.min.js"></script>
    <style>
        .nr div {
            margin: 15px;
            margin-left: 0px;
        }

        td {
            padding: 5px;
            padding-left: 0px;
        }
    </style>
</head>
<body>
    <div id="app">
        <div>您正在做的业务是：人力资源--客户化设置--人力资源档案管理设置--职称设置--职称修改</div>
        <div class="nr">
            <form id="updateForm" method="post" action="/ZCSZ/Update">
                <input type="hidden" name="major_zwid" v-model="titleData.major_zwid">
                <table>
                    <tr>
                        <td>职位编号： </td>
                        <td><input type="text" size="30" v-model="titleData.major_zwid" disabled /></td>
                    </tr>
                    <tr>
                        <td>职位名称： </td>
                        <td><input type="text" size="30" name="major_name" v-model="titleData.major_name" /></td>
                    </tr>
                </table>
                <div>
                    <button type="submit">修改</button>&nbsp;
                    <button type="button" v-on:click="Ret">返回</button>
                </div>
            </form>
        </div>
    </div>

    <script>
        const { createApp, ref, onMounted } = Vue;

        const app = createApp({
          setup() {
              const titleData = ref({
                  major_zwid: '',
                  major_name: ''
              });
              
              // 获取URL中的参数
              const getUrlParam = (name) => {
                  const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
                  const r = window.location.search.substr(1).match(reg);
                  if (r != null) return decodeURIComponent(r[2]);
                  return null;
              }
              
              // 加载职称数据
              const loadTitleData = async () => {
                  const id = getUrlParam('id');
                  if (!id) {
                      ElementPlus.ElMessage.error('未获取到职称ID');
                      return;
                  }
                  
                  try {
                      const res = await axios.get(`/ZCSZ/GetTitleById?id=${id}`);
                      titleData.value = res.data;
                  } catch (err) {
                      console.error(err);
                      ElementPlus.ElMessage.error('获取职称数据失败');
                  }
              }
              
              
              const Ret = () => {
                  window.location.href = '/ZCSZ/Index';
              };

              // 页面加载时获取职称数据
              onMounted(() => {
                  loadTitleData();
              });

             return {
                 titleData,
                 Ret
             }
          }
        });

        app.use(ElementPlus);
        app.mount('#app');
    </script>
</body>
</html>